import cookie from "@/utils/store/cookie";
import {
		VUE_APP_API_URL
	} from "@/config";
export const customUpdateAvatar = (filePath) => {
	console.log(filePath)
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: `${VUE_APP_API_URL}/user/update/avatar`,
			filePath: filePath,
			name: 'file',
			formData: {
				bucketName: 'avatar/',
			},
			header: {
				'token': cookie.get('login_status'),
				// 'token': 'a82472c6-96c9-46b0-a018-783dea7864b5',
				'content-type': 'multipart/form-data' // 默认值
			},
			success: uploadFileRes => {
				if (uploadFileRes.statusCode === 200) {
					var dataResult = JSON.parse(uploadFileRes.data).data;
					resolve(dataResult)
				} else {
					uni.showToast({
						title: '上传失败',
						icon: 'none'
					});
				}
			},
			fail(e) {
				console.log(e)
				uni.showToast({
					title: '上传失败',
					icon: 'none'
				});
			}
		})
	})
}